package com.googlecode.jlogindexer.client;

import org.apache.commons.io.input.Tailer;
import org.apache.commons.io.input.TailerListenerAdapter;


public class JLogalizerTailerListener extends TailerListenerAdapter{
	
	private String clientId;
	private String hostname;
	private String fileName;
	private JLogMessageSender messageSender=null;
	
	public JLogalizerTailerListener(String clientId, String hostname, String fileName) {
		super();
		this.clientId = clientId;
		this.hostname = hostname;
		this.fileName = fileName;
	}

	public void fileNotFound() {

		System.out.println("File not found");
	}

	public void fileRotated() {
		System.out.println("File rotated");

	}

	public void handle(String eachLine) {
		System.out.println("each LIne : "+eachLine);
		messageSender.publishLog(clientId, hostname, fileName, eachLine);
		
	}
	
	

	
	
	public JLogMessageSender getMessageSender() {
		return messageSender;
	}

	public void setMessageSender(JLogMessageSender messageSender) {
		this.messageSender = messageSender;
	}

	public void handle(Exception exception) {
		System.out.println("Exeption :: "+exception.getMessage());
	}

	public void init(Tailer tailer) {
		System.out.println("init method called.");
		
	}
}
